package com.example.online_order.mapper;

import com.example.online_order.pojo.AdminAccount;
import com.example.online_order.pojo.ClientAccount;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ClientAccountMapper {
    //    新增，删除，修改，查询（用户名查询  全表查询）

    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    @Insert("insert into clientAccount (id,userName,password,identify,phone,birthday,avatar) values (null,#{userName}, #{password},#{identify},#{phone},#{birthday},#{avatar})")
    public Integer addclient(ClientAccount clientAccount);

    @Delete("delete from clientAccount where id =#{id}")
    public Integer deleteClient(Integer id);

    @Update("update clientAccount set userName= #{userName}, password= #{password}, identify= #{identify}, phone= #{phone}, birthday= #{birthday}, avatar=#{avatar} where id = #{id}")
    public Integer updateClient(ClientAccount clientAccount);

    @Select("select * from clientAccount")
    public List<ClientAccount> getAllClient();

    @Select("select * from clientAccount where userName= #{userName}")
    @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
    public ClientAccount findClientByUsername(String username);

    @Select("select * from clientAccount where userName like '%${userName}%' ")
    public List <ClientAccount> findClientLikeUsername(String username);


    @Select("select * from clientAccount where id= #{id}")
    public  ClientAccount findClientById(Integer id);

    @Update("update clientAccount set password = #{password} where id= #{id}")
    Integer updateClientPassword(ClientAccount clientAccount);
}
